<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Symbol</title>

</head>

<body>

    <script>

        let s1=Symbol("foo");

        let s2=Symbol("foo");

 

        console.log(s1);

        console.log(typeof(s1));

        console.log(s2.toString());

        let obj={

            [s1]:"yuanlei",

            sx:"shuxingzhi"

        }

        console.log(obj[s1]);

        let f1=Symbol.for("foo");

        let f2=Symbol.for("foo");

        console.log(f1==f2);

        console.log(Symbol.keyFor(f1));//获得key

    </script>

</body>

</html>